<!--
 * @Author: 孙家旺 sun2622580997@163.com
 * @Date: 2025-04-11 22:16:07
 * @LastEditors: 孙家旺 sun2622580997@163.com
 * @LastEditTime: 2025-09-18 15:29:28
 * @FilePath: \chatBot\src\components\initializationChat\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<script setup lang="js">
    import { ref, provide, onMounted } from 'vue'
    import { useRouter } from 'vue-router'
    import chatInput from '../chatInput/index.vue'

    const router = useRouter()

    // 快捷发送消息
    const clickBootstrapping = () => {
        const params = {};
        params.content = "为什么成年人比小孩更害怕犯错？"; // 发送消息
        params.model = 'deepseek-v3'; // 模型
        params.session_id = localStorage.getItem("sessionId") ? localStorage.getItem("sessionId") : ''; // 会话id聊天id
        localStorage.removeItem("sessionId")
        localStorage.setItem("initialization", params)
        router.push('/chatBot/initialization')
    }

    // 初始化缓存数据
    onMounted(() => {
        localStorage.removeItem('isRefresh')
        localStorage.removeItem('knowledgeId')
        localStorage.removeItem('databaseName')
    })

    // 获取子组件值
    provide('chatMessage', (value) => {
        localStorage.setItem("initialization", JSON.stringify(value))
        const initialization = value.session_id ? value.session_id : 'initialization'
        router.push(`/chatBot?id=${initialization}`)
    })

</script>

<template>
    <div class="initialization-content">
        <div class="title">我是DataMed AI+，很高兴见到你！</div>
        <chatInput chatType="newChat" modelType="Deepseek" />
        <!-- <div class="bootstrapping">
            <div class="tip-title">例如，您可以这样问我：</div>
            <div class="bootstrapping-item" @click="clickBootstrapping" v-for="item in 3" :key="item">
                <span>为什么成年人比小孩更害怕犯错？</span>
            </div>
        </div> -->
    </div>
</template>

<style scoped lang="scss">
    .initialization-content {
        width: 800px;
        height: 100%;

        .title {
            color: #000;
            font-size: 36px;
            font-weight: bold;
            text-align: center;
            margin-top: 26vh;
            margin-bottom: 50px;
        }

        .bootstrapping {
            color: #999999;
            font-size: 14px;
            margin-top: 30px;

            .bootstrapping-item {
                margin-top: 12px;
                display: flex;

                span {
                    font-size: 14px;
                    color: #585858;
                    padding: 6px 10px;
                    cursor: pointer;
                    background-color: #fff;
                    border-radius: 10px;
                }
            }
        }

    }
</style>